package org.autumn.pool;


import java.util.concurrent.*;

public class TestThreadPool {

    public static void main(String[] args) {

        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                1,
                10,
                10,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1));

        for (int i = 0; i < 10  ; i++) {
            executor.execute(()->{
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + ": execute ..." );
            });
        }

        executor.shutdown();
//        ExecutorService executorService = Executors.newSingleThreadExecutor();
//        ExecutorService executorService1 = Executors.newFixedThreadPool(1);

    }
}
